package com.zzw.basic.io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class FilesTest {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		String name = new String("../ReflectDemo/src/main/java/com/zzw/io/FilesTest.java");
		String txt = new String("../ReflectDemo/src/main/resources/test.txt");
		Files.copy(Paths.get(name), new FileOutputStream(txt));
		System.out.println("FilesTest.java �Ƿ�Ϊ�����ļ�:" + Files.isHidden(Paths.get(name)));
		List<String> lines = Files.readAllLines(Paths.get(name),Charset.forName("gbk"));
		System.out.println(lines);
		System.out.println("FilesTest.java�Ĵ�СΪ:" + Files.size(Paths.get(name)));
		List<String> poem = new ArrayList<String>();
		poem.add("121312312088");
		poem.add("123124124898");
		Files.write(Paths.get(txt), poem, Charset.forName("gbk"));
		Files.list(Paths.get(".")).forEach(path->System.out.println(path));
		Files.lines(Paths.get(name),Charset.forName("gbk")).forEach(line -> System.out.println(line));
		FileStore cStore = Files.getFileStore(Paths.get("C:"));
		System.out.println(cStore.getTotalSpace());
		System.out.println(cStore.getUsableSpace());
	}

}
